Creating a Report

I have a series of 5 validation scripts that can now be run from a menu within the module.

Currently, the scripts run within attributes, so running them from the menu instead simply refreshes these columns. However, I require to have the validation results for each object populate a report instead, in the form of an unsaved word/notepad document that will pop-up on the screen allowing the user to then view it and save it in the location of their choice.

I don't know how to do this (or if it is even possible). I.e. Can you send dxl outputs to populate a word document that hasn't yet been saved, and how do I make it appear on the screen?

Alternatively, I noticed the 'fileName' DBE option. I have implemented this on one of the scripts to prompt the user to enter the path and filename of the 'results' file (complete with browse button), and then my script succesfully populates this file. If I could get this function to prompt the user for a path only, rather than an actual file that pre-exists, then this should satisfy my requirement. Do you know if this can be done? (i.e. a 'pathName' DBE or equivilent?)

I would very much appreciate any assistance or examples you could provide.

Regards.

Simon Gwilliam
simon.gwilliam - Fri Mar 19 10:36:18 EDT 2010

Re: Creating a Report
Mathias Mamsch - Fri Mar 19 10:48:41 EDT 2010

I guess the easiest way to show your results (a string i guess?) on the screen is create a small dialog:
 

string reportString = "
This is my {\\b report}. 
It has {\\i very cewl } data in it and can also use bold, 
italics { \\ul underlined } text!
"
 
DB x = centered "Report Results" 
richText (x, "Copy this data where you like to have it", richText reportString , 300,300, true) 
show x

 


For sure you could also make a filename chooser and give the user a button where he can save the dialog results.

Regards, Mathias

 

Re: Creating a Report
simon.gwilliam - Fri Mar 19 11:00:10 EDT 2010

Mathias Mamsch - Fri Mar 19 10:48:41 EDT 2010

I guess the easiest way to show your results (a string i guess?) on the screen is create a small dialog:
 

string reportString = "
This is my {\\b report}. 
It has {\\i very cewl } data in it and can also use bold, 
italics { \\ul underlined } text!
"
 
DB x = centered "Report Results" 
richText (x, "Copy this data where you like to have it", richText reportString , 300,300, true) 
show x

 


For sure you could also make a filename chooser and give the user a button where he can save the dialog results.

Regards, Mathias

 

I'm familiar with showing test in Dialog Boxes, but I didn't realise you could then give the user an option to save this as a .txt in the location of their choice. How on earth do you do that?

Thanks for responding btw.

Re: Creating a Report
Mathias Mamsch - Fri Mar 19 11:27:20 EDT 2010

simon.gwilliam - Fri Mar 19 11:00:10 EDT 2010
I'm familiar with showing test in Dialog Boxes, but I didn't realise you could then give the user an option to save this as a .txt in the location of their choice. How on earth do you do that?

Thanks for responding btw.

Just a few more lines ... you can copy/paste a lot of the DOORS dxl help file. Regards, Mathias
 

DBE rt
 
void storeData(DBE bt) {
     // basic file name 
    DB storer = centered ("Choose a location")
    DBE fn = fileName(storer, "input.dat") 
    block storer
    release storer
    string file = get fn
    if (!canOpenFile(file, true)) { ack "Cannot open file " file "\n"; return }
    Stream outStream = write file 
    string result = get rt
    outStream << result 
    close outStream 
}
 
string reportString = "
This is my {\\b report}. 
It has {\\i very cewl } data in it and can also use bold, 
italics { \\ul underlined } text!
"
 
 
DB x = centered "Report Results" 
rt = richText (x, "Copy this data where you like to have it", richText reportString , 300,300, true) 
button (x, "Save to file", storeData) 
show x

Re: Creating a Report
llandale - Fri Mar 19 18:08:51 EDT 2010

Not sure what you are asking, but the following will output the contents of a buffer to a text file and display it with Notepad.exe.

//*************************
bool    fFileMessage(Buffer  bufContents, string NameFile, bool DisplayFile)
{     // Put string FileContents in the NameFile and optionally display it with Notepad.exe
        // FileContents must already be formatted if at all.
        // Return true if it appears to have worked.
 
        Stream  Output
        noError()
        Output  = write(NameFile)
        string  ErrMess = lastError()
        if (!null Output and null ErrMess)
        {  Output << bufContents
           close Output
           if (DisplayFile)
              system("Notepad.exe " NameFile)
           return(true)
        }
        else
        {  return(false)
        }
}     // end fFileMessage()
 
//*************************
bool  fFileMessage(Buffer bufContents)
{     // Overloaded, get a temp file name and yes display the file
        return(fFileMessage(bufContents, tempFileName(), true))
}     // end overloaded fFileMessage(temp file)s
 
 
Buffer buf = create
buf = "(((("
fFileMessage(buf)
delete(buf)